<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title></title>
    <style>
      .box1{
        width: 100px;
        height: 100px;
        background: green;
      }
      .box2{
        width: 250px;
        height: 250px;
        background: red;
      }
      /* 默认的类实现的动画  v-开头的六个类*/
      .v-enter,.v-leave-to{
        opacity: 0;
        transform: translateX(200px);
      }
      .v-enter-active,.v-leave-active{
        transition: all 2s;
      }
      /* transition有自己的名字，例如box2name   box2-开头的六个类 */
      .box2-enter,.box2-leave-to{
        height: 0px;
        opacity: 0;
      }
      .box2-enter-active,.box2-leave-active{
        transition: all 1s;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <button @click="isShow=true">进入</button>
      <button @click="isShow=false">离开</button>
      <transition>
        <!-- 从右侧200px的位置淡入进来 -->
        <!-- 慢慢的淡出到右侧200px位置 -->
        <div class="box1" v-if="isShow"></div>
      </transition>

      <hr>
      <button @click="isShow1=true">进入</button>
      <button @click="isShow1=false">离开</button>
      <transition name="box2">
        <!-- 高度0px到250px 1s的动画 进入-->
        <!-- 高度250px到0px 1s的动画 离开-->
        <div class="box2" v-show="isShow1"></div>
      </transition>
    </div>
    <script src="./vue.js"></script>
    <script>
      const vm = new Vue({
        el: '#app',
        data: {
          isShow: true,
          isShow1: true
        }
      })
    </script>
  </body>
</html>